# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=podman-compose
pkgver=1.0.6
pkgrel=2
pkgdesc='A script to run docker-compose.yml using podman'
arch=(any)
url='https://github.com/containers/podman-compose'
license=(GPL2)
depends=(
  podman
  podman-dnsname
  python
  python-dotenv
  python-yaml
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
)
source=($pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz)
sha512sums=('eb6972c51fd02c7a7dec364d18417c4f093f12ab90ba7061be189de7130c8eb0becb5a1653ebf7db0611470b52257a4a1eaae52891f434ca73fbc6dd30da5f56')
b2sums=('4a200d7abb77535d631704e96f600c360cd03a70274c5ed763a6f21a309f9be1225749e4f34b1df00973e9c1de191ec3d43bf35588d912faac25de52e4dd85be')

build() {
  cd $pkgname-$pkgver

  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    -vv
    --deselect tests/test_podman_compose.py::test_podman_compose_extends_w_file_subdir
  )
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $pkgname-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$PWD/test_dir/$site_packages:$PYTHONPATH"
  pytest "${pytest_options[@]}"
}

package() {
  cd $pkgname-$pkgver

  python -m installer --destdir="$pkgdir" dist/*.whl
  find examples -type f -exec install -vDm 644 {} "$pkgdir/usr/share/doc/$pkgname/"{} \;
  install -vDm 644 {README.md,docs/*} -t "$pkgdir/usr/share/doc/$pkgname/"
}

# vim:set ts=2 sw=2 et:
